package com.zjy.pgcms.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zjy.pgcms.dto.reservation.ReservationInfo;
import com.zjy.pgcms.dto.reservation.ReservationPage;
import com.zjy.pgcms.entity.Reservation;
import com.zjy.pgcms.service.ReservationService;
import com.zjy.pgcms.mapper.ReservationMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 *
 */
@Service
public class ReservationServiceImpl extends ServiceImpl<ReservationMapper, Reservation>
    implements ReservationService{

    @Resource
    private ReservationMapper reservationMapper;
    @Override
    public List<ReservationInfo> queryReservationByUserId(Long userId) {
        return reservationMapper.getReservation(userId);
    }

    @Override
    public List<ReservationInfo> getReservationCompleted() {
        return reservationMapper.getReservationCompleted();
    }

    @Override
    public List<ReservationInfo> getReservationUnExpired() {
        return reservationMapper.getReservationUnExpired();
    }

    @Override
    public List<ReservationInfo> getReservationExpired() {
        return reservationMapper.getReservationExpired();
    }

    @Override
    public List<ReservationInfo> queryReservationByCondition(Map<String, Object> params) {
        return reservationMapper.selectReservationByMap(params);
    }

    @Override
    public List<ReservationPage> queryByPage(Map<String, Object> params) {
        return reservationMapper.selectByPage(params);
    }

    @Override
    public boolean setStatus(long id, int status) {
        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("id",id);
        hashMap.put("status",status);
        int i = reservationMapper.setStatus(hashMap);
        if (i > 0){
            return true;
        }
        return false;
    }
}




